Skip to content

Comments

[CAMEL 21975] Jbang diagram command to visualize camel routes#21534

Draft
vignesh-manel wants to merge 3 commits intoapache:mainfrom
vignesh-manel:CAMEL-21975
Draft

[CAMEL 21975] Jbang diagram command to visualize camel routes#21534
vignesh-manel wants to merge 3 commits intoapache:mainfrom
vignesh-manel:CAMEL-21975

Conversation

@vignesh-manel
Copy link
Contributor

Description

Added Playwright-based PNG export for camel diagram via hawtio and Jolokia

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

@davsclaus
Copy link
Contributor

Thanks for helping with jbang. Can you make this into its own plugin as this should not be in the core.

You can look at one of the existing pluigins such as the new validate
https://github.com/apache/camel/tree/main/dsl/camel-jbang/camel-jbang-plugin-validate

<pgjdbc-ng-driver-version>0.8.9</pgjdbc-ng-driver-version>
<picocli-version>4.7.7</picocli-version>
<pinecone-client-version>3.1.0</pinecone-client-version>
<playwright-version>1.43.0</playwright-version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version is quite old, can you use the latest 1.58.0?


@CommandLine.Command(name = "diagram", description = "Visualize Camel routes using Hawtio", sortOptions = false,
showDefaultValues = true)
public class Diagram extends CamelCommand {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is quite big, can you split it in smaller classes?

There is javascript code that is hard to read as it is, please put the js code in the resource folder in .js files.

if (hawtioProcess != null && !hawtioProcess.process.isAlive()) {
throw new IllegalStateException("Hawtio terminated before startup." + formatHawtioOutput(hawtioProcess.output));
}
Thread.sleep(500);
Copy link
Contributor

@Croway Croway Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fragile, would it be possible to implement some kind of polling healthcheck instead?

return true;
}
try {
Thread.sleep(200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Locator expandAll = page.locator("#camel-tree-view button:has-text(\"Expand all\")");
if (expandAll.count() > 0) {
expandAll.first().click();
page.waitForTimeout(300);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fragile as well, there may be alternatives like waitForSelector, or waitForFunction, waitForResponse that can be used instead

Locator expandAll = page.locator("#camel-tree-view button:has-text(\"Expand all\")");
if (expandAll.count() > 0) {
expandAll.first().click();
page.waitForTimeout(300);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

if (search.count() > 0) {
search.fill(routeId);
page.waitForTimeout(300);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


private void normalizeDiagramLayout(Page page) {
try {
page.evaluate("(() => {"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to its own js file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants